/*
* @Author: mmall
* @Date:   2017-05-27 17:57:49
* @Last Modified by:   Administrator
* @Last Modified time: 2017-11-30 12:57:15
*/

$(function(){

    $("footer").load("layout/footer.html");
    $("header").load("layout/header2.html");

    var navHtml=$('#nav').html();
    var listHtml=$("#wbclist").html(); 
    var selectHtml=$("#select").html(); 
// 分类导航
$(function() {
              $.ajax({
                       type:"get",
                       url:"data/wobiancaonav.json",
                       async:true,
                       success: function(data){
                        console.log(data.nav.length);
                        var navdata=data.nav
                        var selectdata=data.select
                        $('.navlis').html(doT.template(navHtml)(navdata));
                        $('select').html(doT.template(selectHtml)(selectdata));
                       },
                       error: function(XMLHTTPRequest, textStatus, errorThrown){
                         console.log("XMLHttpRequest :"+ XMLHTTPRequest);
                         console.log("textStatus :"+textStatus);
                         console.log("errorThrown :"+errorThrown);
                       }
                     });
             
       
    });

$(document).on("click",".navlis button",function(){
  $(this).addClass("changered").siblings().removeClass("changered");
  console.log("111")
})
$(document).on("click",".sort-item",function(){
  $(this).addClass("changered").siblings().removeClass("changered");
})
// 列表
  //分页 
    function ajaxTest(num) {
      $.ajax({
        url: "data/wobiancao.json",
        type: "get",
        data: {},
        dataType: "json",
        success: function(data) {
          // console.log(data);
           var listdata=data.list;
           $('.p-list-con').html(doT.template(listHtml)(listdata));
           $("html,body").animate({
              "scrollTop" : 0
            },400);
          //分页
          $("#page").paging({
            pageNo: 1,
            totalPage: 5,
            totalSize: 20,
            callback: function(num) {
              console.log(typeof data)
              ajaxTest(num)
            }
          })
        }
      })
    }

   ajaxTest(1);

            $(document).ready(function(){
               
            });
        // 选中内容增添删除样式
          $(document).on("click",".navlis li:nth-child(1) .casebtn button",function(){
              $(this).addClass("changered").siblings().removeClass("changered");
              var html=$(this).html()
              $(".wbc-del-check ul .wbc-del-bigli").show().find("span").html(html)
          })
          $(document).on("click",".navlis li:nth-child(2) .casebtn button",function(){
              $(this).addClass("changered").siblings().removeClass("changered");
              var html=$(this).html()
              $(".wbc-del-check ul .wbc-del-smallli").show().find("span").html(html)
          })

          $(document).on("click",".clear-check",function(){
                $(".wbc-del-check ul li").hide();
                $(".casebtn button").removeClass("changered");
                
          });

        
        // 删除选择按钮
        $(document).on("click",".wbc-del-bigli .wbc-del-btn",function(){
           $(this).parent("li").remove();
           $(".checkedclass span").removeClass("changered");
        })
        $(document).on("click",".wbc-del-smallli .wbc-del-btn",function(){
           $(this).parent("li").remove();
           $(".wbc-lis2-list .checkedclass").removeClass("changered");
        })    



})

  